package com.lc.rongzecaifu.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.lc.rongzecaifu.MyApplication;
import com.lc.rongzecaifu.conn.JsonInvestList;
import com.lc.rongzecaifu.rongzecaifu.R;
import com.zcx.helper.bound.BoundView;
import com.zcx.helper.bound.BoundViewHelper;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/2/24.
 */
public class InvestDetailAdapter extends RecyclerView.Adapter<InvestDetailAdapter.ReHolder>{

    private LayoutInflater layoutInflater;
    private Context context;
    private List<JsonInvestList.Info.ListContent> lists = new ArrayList<>();

    public InvestDetailAdapter(Context context, List<JsonInvestList.Info.ListContent> lists) {

        this.lists = lists;

        layoutInflater = LayoutInflater.from(context);

        this.context = context;
    }

    @Override
    public ReHolder onCreateViewHolder(ViewGroup parent, int viewType) {

        View view = MyApplication.scaleScreenHelper.loadView((ViewGroup) layoutInflater.inflate(R.layout.item_recy_detail_list, null));

        ReHolder holder = new ReHolder(view);

        return holder;
    }

    @Override
    public void onBindViewHolder(ReHolder holder, int position) {

        holder.account_date.setText(lists.get(position).deadline);
        holder.account_money.setText(lists.get(position).capital);
        holder.account_Interest.setText(lists.get(position).interest);
        holder.account_shouxufei.setText(lists.get(position).interest_fee);
        holder.shiji_benxi.setText(lists.get(position).receive_all);
        holder.yingshou_benxi.setText(lists.get(position).capital_all);
        holder.shiji_status.setText(lists.get(position).status_cn);
        holder.shiji_countbi.setText(lists.get(position).sort_order);

    }

    @Override
    public int getItemCount() {
        return lists.size();
    }

    public class ReHolder extends RecyclerView.ViewHolder {

        @BoundView(R.id.account_date) TextView account_date;
        @BoundView(R.id.account_money) TextView account_money;
        @BoundView(R.id.account_Interest) TextView account_Interest;
        @BoundView(R.id.account_shouxufei) TextView account_shouxufei;
        @BoundView(R.id.shiji_benxi) TextView shiji_benxi;
        @BoundView(R.id.yingshou_benxi) TextView yingshou_benxi;
        @BoundView(R.id.shiji_status) TextView shiji_status;
        @BoundView(R.id.shiji_countbi) TextView shiji_countbi;

        public ReHolder(View itemView) {
            super(itemView);

            BoundViewHelper.boundView(this, itemView);

        }
    }
}
